home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / serial / callback.001 / callback~ / callback / lib / user / combine.c next >
C/C++ Source or Header  |  1996-07-23  |  929b  |  40 lines

  1.  
  2. #include "user.p"
  3.  
  4. int combine(int uid, char *where)
  5. {
  6.     unsigned
  7.     index,
  8.     dest;
  9.     char
  10.     *dname;
  11.  
  12.  
  13.     if (look_dname(where) == -1)        /* can we get there ?   */
  14.         return (-1);                    /* no, return -1        */ 
  15.  
  16.                                         /* walk the destinations */
  17.     for (dest = get_ndestinations(); dest--; )
  18.     {
  19.     dname = get_dname(get_dnameindex(dest));    /* keep its name */
  20.  
  21.     if (!strcmp(where, dname))        /* target matches request */
  22.     {
  23.         for (index = user_ngroups(uid); index--; )
  24.         {                    /* matching group was found */
  25.         if (usergroup(uid, index) == get_dgroupindex(dest))
  26.         {
  27.             log(log_on, "Destination %s: ok", where);
  28.             return (dest);        /* then return the destin.-id */
  29.         }
  30.         }
  31.         log(log_on, "Destination %s: no available group", where);
  32.     }
  33.     else
  34.         log(log_max, "Comparing %s to %s: no match", dname, where);
  35.     }
  36.  
  37.     return (-1);               
  38. }
  39.  
  40.